import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComboBox;


public class ViewAppointmentsGUI extends JPanel{
    int location;
    User user;
    Date date;
    List<Appointment> app;
    private JTextField textField;
    
    public ViewAppointmentsGUI() {
        setLayout(null);
        
        final JComboBox comboBox = new JComboBox();
        comboBox.setBounds(10, 66, 430, 47);
        add(comboBox);
        
        textField = new JTextField();
        textField.setBounds(132, 10, 120, 20);
        add(textField);
        textField.setColumns(10);
        
        JButton btnSearch = new JButton("Search");
        btnSearch.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 12;
                int j = 0;
                for( int i = 0; i < app.size(); i++)
                {
                    if(app.get(i).getDate() == date)
                    {
                    comboBox.insertItemAt(app.get(i).getTimeStart()+ " "+ app.get(i).getPatient(), j);
                    j++;
                    }
                }
            }
        });
        btnSearch.setBounds(262, 9, 89, 23);
        add(btnSearch);
        
        JLabel lblMonth = new JLabel("Date yyy-mm-dd");
        lblMonth.setBounds(10, 13, 112, 14);
        add(lblMonth);
        
        JButton btnCancel = new JButton("Cancel");
        btnCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 21;
            }
        });
        btnCancel.setBounds(262, 32, 89, 23);
        add(btnCancel);
        
        
    }
    public int getLoc(){
        return location;
    }
    
    public void setLoc(int i){
        location = i;
    }
    
    public Date getDate(){
        return date;
    }
    
    public void setAppointments(List<Appointment> input){
        app = input;
    }
}
